@extends('public.layouts')
@section('style')
    <meta name="_token" content="{{ csrf_token() }}"/>
    <style>
        .task-table-th {
            text-align: center;
        }
        .task-table-td {
            text-align: center;
        }
        .keyword{
            max-width: 300px;
        }
        .keyword-btn{
            max-width: 80px;
        }
        .patent-list-th{
            text-align: center;
        }
        .patent-list-td{
            text-align: center;
        }
        .trademark-list-th{
            text-align: center;
        }
        .trademark-list-td{
            text-align: center;
        }
        #patent-list{
            max-height: 400px;
            overflow-y: auto;
        }
        #trademark-list{
            max-height: 400px;
            overflow-y: auto;
        }
    </style>
    <link rel="stylesheet" href="{{asset('admin_assets/css/bootstrap-datetimepicker.min.css')}}">
    <link rel="stylesheet" href="{{url('css/search.css')}}">
@stop
@section('content')
    <div class="content-wrapper" style="background-color: white">
        <section id="list" class="content">
            <div class="row">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <div class="box box-info"
                         style="padding-top: 0px;margin-top: 0px;border-top: 0px;border-bottom: solid 1px #009aff;">
                        <div class="box-body" style="">
                            <div class="row">
                                <div class="col-lg-2 col-md-2 col-sm-12 col-xs-12" style="margin-top: 1%">
                                    <a href="#" title="返回首页" style="float: left"><i class="fa fa-home fa-2x"
                                                                                    style="width: 100%;color: #009aff">
                                        </i></a>
                                    <a href="{{url('user/work/index')}}"><span
                                                style="font-size: 20px;float: left;color: #009aff">&nbsp;工作台</span></a>
                                    <div class="clear"></div>
                                </div>
                                <div class="col-lg-2 col-md-2 col-sm-12 col-xs-12  col-lg-offset-8 col-md-offset-8">
                                    <form action="{{url('user/work/indexSearch')}}" method="post" enctype="multipart/form-data" class="search">
                                        {{csrf_field()}}
                                        <button type="submit" class="fa fa-search fa-lg"></button>
                                        <input type="search" class="search" value="{{$keywords}}" id="search-input" name="search">
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            @include('public/alert')
            <div class="row">
                <div class="col-lg-3 col-md-6 col-sm-12 col-xs-12">
                    <div class="small-box bg-aqua" style="background: #37A8F4">
                        <div class="inner" style="background: #37A8F4">
                            <h3>{{$count[0]}}</h3>
                            <p>专利数量</p>
                        </div>
                        <div class="icon">
                            <img src="{{asset('admin_assets/img/patent_icon.png')}}"
                                 style="width: 100px;height: 100px;margin-left: 0;margin-top: -20px">
                        </div>
                        <a href="{{url('user/mine/myPatent')}}" class="small-box-footer" style="background: #009aff">详情<i class="fa fa-arrow-circle-right"></i></a>
                    </div>
                </div>
                <div class="col-lg-3 col-md-6 col-sm-12 col-xs-12">
                    <div class="small-box bg-aqua" style="background: #8BC44A">
                        <div class="inner" style="background: #8BC44A">
                            <h3>{{$count[1]}}</h3>
                            <p>商标数量</p>
                        </div>
                        <div class="icon">
                            <img src="{{asset('admin_assets/img/trademark_icon.png')}}"
                                 style="width: 100px;height: 100px;margin-left: 0;margin-top: -20px">
                        </div>
                        <a href="{{url('user/mine/myTrademark')}}" class="small-box-footer" style="background: #72aa49">详情<i class="fa fa-arrow-circle-right"></i></a>
                    </div>
                </div>
                <div class="col-lg-3 col-md-6 col-sm-12 col-xs-12">
                    <div class="small-box bg-aqua" style="background: #FFBA00">
                        <div class="inner" style="background: #FFBA00">
                            <h3>{{$count[2]}}</h3>
                            <p>版权数量</p>
                        </div>
                        <div class="icon">
                            <img src="{{asset('admin_assets/img/copyright_icon.png')}}"
                                 style="width: 100px;height: 100px;margin-left: 0;margin-top: -20px">
                        </div>
                        <a href="{{url('user/mine/myCopyright')}}" style="background: #c69200" class="small-box-footer">详情<i class="fa fa-arrow-circle-right"></i></a>
                    </div>
                </div>
                <div class="col-lg-3 col-md-6 col-sm-12 col-xs-12">
                    <div class="small-box bg-aqua" style="background: #F4521E">
                        <div class="inner" style="background: #F4521E">
                            <h3>{{$count[3]}}</h3>
                            <p>项目数量</p>
                        </div>
                        <div class="icon">
                            <img src="{{asset('admin_assets/img/project_icon.png')}}"
                                 style="width: 100px;height: 100px;margin-left: 0;margin-top: -20px">
                        </div>
                        <a href="{{url('user/mine/myProject')}}" style="background: #e14b1c" class="small-box-footer">详情<i class="fa fa-arrow-circle-right"></i></a>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <div class="table-responsive">
                        <table class="table table-bordered">
                            <thead>
                            <tr>
                                <th class="task-table-th">任务编号</th>
                                <th class="task-table-th">申请人</th>
                                <th class="task-table-th">任务类别</th>
                                <th class="task-table-th">类型</th>
                                <th class="task-table-th">任务发起时间</th>
                                <th class="task-table-th">任务状态</th>
                                <th class="task-table-th">任务等级</th>
                                <th class="task-table-th">执行人</th>
                            </tr>
                            </thead>
                            <tbody class="list">
                            @if($product->isEmpty())
                                <tr>
                                    <td class="task-table-td" colspan="8"><h3 align="center">暂无数据</h3></td>
                                </tr>
                            @else
                                @php($i=0)
                                @foreach($product as $k =>$c)
                                    @php($v =$c['Product'])
                                    @if(!empty($c['FirstType']))
                                        <tr>
                                            <td class="task-table-td" style="vertical-align: middle">{{++$i}}</td>
                                            <td class="task-table-td"
                                                style="vertical-align: middle">{{$v['applicant']}}</td>
                                            <td class="task-table-td" style="vertical-align: middle">
                                                @if($c['is_renew']==0)
                                                    首次任务
                                                @else
                                                    续费任务
                                                @endif
                                            </td>
                                            <td class="task-table-td"
                                                style="vertical-align: middle">{{$c['FirstType']['name']}}</td>
                                            <td class="task-table-td"
                                                style="vertical-align: middle">{{date("Y-m-d",strtotime($v['created_at']))}}</td>
                                            <td class="task-table-td"
                                                style="vertical-align: middle">{{config('config.product_state')[$c['state']]}}</td>
                                            <td class="task-table-td"
                                                style="vertical-align: middle">{{config('config.product_level')[$v['level']]}}</td>
                                            <td class="task-table-td" style="vertical-align: middle">
                                                @if(empty($c['agent']))
                                                    暂无
                                                @else
                                                    {{$c['agent']}}
                                                @endif
                                            </td>
                                        </tr>
                                    @endif
                                @endforeach
                            @endif
                            </tbody>
                        </table>
                        <div class="">
                            {!! $product->links() !!}
                        </div>
                    </div>
                </div>
            </div>
            <div class="row" style="margin-top: 2%">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <div class="table-responsive">
                        <div id="trademark-list" class="box">
                            <div class="box-header">
                                <h3 class="box-title" style="vertical-align: middle;margin-top: 10px">商标列表</h3>
                                <form action="#" method="post" onsubmit="return false;" enctype="multipart/form-data" style="width: 70%;height: 40px;float: right">
                                    <button type="submit" onclick="getTrademark();" class="btn btn-info keyword-btn" style="background: #009aff;width: 15%;float: right;">查询</button>
                                    <input type="text" id="trademarkSearch" class="form-control keyword" placeholder="申请人/名称/申请人/内部编码/案件状态" style="width: 85%;border-radius: 5px;float: right">
                                </form>
                            </div>
                            <div class="box-body no-padding">
                                <table class="table table-bordered">
                                    <thead>
                                    <tr>
                                        <th class="trademark-list-th">#</th>
                                        <th class="trademark-list-th">名称</th>
                                        <th class="trademark-list-th">申请人</th>
                                        <th class="trademark-list-th">申请公司</th>
                                        <th class="trademark-list-th">申请时间</th>
                                        <th class="trademark-list-th">状态</th>
                                    </tr>
                                    </thead>
                                    <tbody id="trademarkSearchList">
                                    <tr>
                                        <td class="trademark-list-td" colspan="6"><h3 align="center">暂无数据</h3></td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row" style="margin-top: 2%">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <div class="table-responsive">
                        <div id="patent-list" class="box">
                            <div class="box-header">
                                <h3 class="box-title" style="vertical-align: middle;margin-top: 10px">专利列表</h3>
                                <form action="#" method="post" onsubmit="return false;" enctype="multipart/form-data" style="width: 70%;height: 40px;float: right">
                                    <button type="submit" onclick="getPatent();" class="btn btn-info keyword-btn" style="background: #009aff;width: 15%;float: right;">查询</button>
                                    <input type="text" id="patentSearch" class="form-control keyword" placeholder="申请人/名称/申请人/内部编码/案件状态" style="width: 85%;border-radius: 5px;float: right">
                                </form>
                            </div>
                            <div class="box-body no-padding">
                                <table class="table table-bordered">
                                    <thead>
                                    <tr>
                                        <th class="patent-list-th">#</th>
                                        <th class="patent-list-th">名称</th>
                                        <th class="patent-list-th">申请人</th>
                                        <th class="patent-list-th">专利类型</th>
                                        <th class="patent-list-th">申请时间</th>
                                        <th class="patent-list-th">法律状态</th>
                                    </tr>
                                    </thead>
                                    <tbody id="patentSearchList">
                                    <tr>
                                        <td class="patent-list-td" colspan="6"><h3 align="center">暂无数据</h3></td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>
@stop
@section('javascript')
    <script src="{{asset('admin_assets/js/bootstrap-datetimepicker.min.js')}}"></script>
    <script src="{{asset('js/ip.js')}}"></script>
    <script>
        $(".form_datetime").datetimepicker({
            format: "yyyy-mm-dd hh:ii:ss",
            autoclose: true,
            todayBtn: true,
            minuteStep: 10,
            language: "en"
        });
        function getTrademark() {
            $.ajax({
                url:'{{url('user/work/juheSearchTrademarkList')}}',
                type: 'post',
                dataType: 'json',
                data: {
                    'keyword': $('#trademarkSearch').val()
                },
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                },
                success:function (data) {
                    var e=$('#trademarkSearchList');
                    e.empty();
                    if(data=='0'){
                        e.append('<tr>');
                        e.append('<td class="trademark-list-td" colspan="6"><h3 align="center">暂无数据</h3></td>');
                        e.append('</tr>');
                    }else{
                        var url=window.location.href;
                        var index=url.lastIndexOf("\/");
                        url=url.substring(0,index+1);
                        url+='juheSearchTrademarkDetail';
                        for(var i=0,size=data.length;i<size;i++){
                            var item=data[i];
                            e.append('<tr>');
                            e.append('<td class="trademark-list-td patent-id">'+(i+1)+'</td>');
                            e.append('<td class="trademark-list-td patent-name"><a href="'+url+'?intCls='+item['intCls']+'&regNo='+item['regNo']+' " target=_blank>'+item['tmName']+'</a></td>');
                            e.append('<td class="trademark-list-td patent-apply">'+item['applicantCn']+'</td>');
                            e.append('<td class="trademark-list-td patent-company">'+item['agent']+'</td>');
                            e.append('<td class="trademark-list-td patent-date">'+item['regDate']+'</td>');
                            e.append('<td class="trademark-list-td patent-state">'+item['currentStatus']+'</td>');
                            e.append('</tr>');
                        }
                    }
                }

            });
        }
        function getPatent() {
            $.ajax({
                url:'{{url('user/work/juheSearchPatent')}}',
                type: 'post',
                dataType: 'json',
                data: {
                    'q': $('#patentSearch').val()
                },
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                },
                success:function (data) {
                    var e=$('#patentSearchList');
                    e.empty();
                    if(data=='0'){
                        e.append('<tr>');
                        e.append('<td class="patent-list-td" colspan="6"><h3 align="center">暂无数据</h3></td>');
                        e.append('</tr>');
                    }else{
                        var url=window.location.href;
                        var index=url.lastIndexOf("\/");
                        url=url.substring(0,index+1);
                        url+='juheSearchPatentInfo';
                        for(var i=0,size=data.length;i<size;i++){
                            var item=data[i];
                            e.append('<tr>');
                            e.append('<td class="patent-list-td patent-id">'+(i+1)+'</td>');
                            e.append('<td class="patent-list-td patent-name"><a href="'+url+'?id='+item['id']+'" target="_blank">'+item['title']+'</a></td>');
                            e.append('<td class="patent-list-td patent-apply">'+item['applicant']+'</td>');
                            e.append('<td class="patent-list-td patent-company">'+item['type']+'</td>');
                            e.append('<td class="patent-list-td patent-date">'+item['applicationDate']+'</td>');
                            e.append('<td class="patent-list-td patent-state">'+item['legalStatus']+'</td>');
                            e.append('</tr>');
                        }
                    }
                }

            });
        }
    </script>
@stop
